﻿#include <iostream>

#include <vector>

using namespace std;

//int main()
//
//{
//
//	int ar[] = { 1,2,3,4,5,6,7,8,9,10 };
//
//	int n = sizeof(ar) / sizeof(int);
//
//	vector<int> v(ar, ar + n);
//
//	cout << v.size() << ":" << v.capacity() << endl;
//	for (auto e : v)
//	{
//		cout << e << " ";
//	}
//
//	v.reserve(100);
//
//	v.resize(20);
//
//	cout << v.size() << ":" << v.capacity() << endl;
//
//	v.reserve(50);
//
//	v.resize(5);
//
//	cout << v.size() << ":" << v.capacity() << endl;
//
//}
int main()

{

	int ar[] = { 1,2,3,4,0,5,6,7,8,9 };

	int n = sizeof(ar) / sizeof(int);

	vector<int> v(ar, ar + n);

	vector<int>::iterator it = v.begin();

	while (it != v.end())

	{

		if (*it != 0)

			cout << *it;

		else

			v.erase(it);

		it++;
		

	}

	return 0;

}

class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        if (nums.size() == 0)
        {
            return 0;
        }
        int fast = 1, slow = 1;
        while (fast < nums.size())
        {
            if (nums[fast] != nums[fast - 1])
            {
                nums[slow] = nums[fast];
                slow++;
            }

            fast++;
        }
        return slow;
    }
};

#include <unordered_map>
class Solution {
public:
    int MoreThanHalfNum_Solution(vector<int>& numbers) {
        unordered_map<int, int> hx;
        int n = 0;
        for (int i = 0; i < numbers.size(); i++)
        {
            hx[numbers[i]]++;
            if (hx[numbers[i]] > (numbers.size() / 2))
            {
                n = numbers[i];
                break;
            }
        }

        return n;
    }
};